package cn.hunqing.web.dto;

import cn.hunqing.web.entity.UploadedFile;

public class RetrievedFileDto {
	private String id;
	private String fileName;
	private String absolutePath;
	private String contentType;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getAbsolutePath() {
		return absolutePath;
	}

	public void setAbsolutePath(String absolutePath) {
		this.absolutePath = absolutePath;
	}

	public String getContentType() {
		return contentType;
	}

	public void setContentType(String contentType) {
		this.contentType = contentType;
	}

	public static RetrievedFileDto buildFrom(UploadedFile uploadedFile) {
		if(uploadedFile == null){
			return null;
		}
		RetrievedFileDto result = new RetrievedFileDto();
		result.setAbsolutePath(uploadedFile.getAbsolutePath());
		result.setFileName(uploadedFile.getFileName());
		result.setId(uploadedFile.getId());
		result.setContentType(uploadedFile.getContentType());
		return result;
	}

}
